package com.yehebl.orm.data.connection;

import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.logging.Logger;

import javax.sql.DataSource;


/**
 * 本地数据源 用于临时方便测试
 */
public class LocalDataSource implements DataSource {
	
	private ConnectionManager connectionManager;
	public LocalDataSource(ConnectionManager connectionManager) {
		this.connectionManager=connectionManager;
	}

	@Override
	public PrintWriter getLogWriter() {
		return null;
	}

	@Override
	public void setLogWriter(PrintWriter out) {

	}

	@Override
	public void setLoginTimeout(int seconds) {

	}

	@Override
	public int getLoginTimeout() {
		return 0;
	}

	@Override
	public Logger getParentLogger() {
		return null;
	}

	@Override
	public <T> T unwrap(Class<T> iface) {
		return null;
	}

	@Override
	public boolean isWrapperFor(Class<?> iface) {
		return false;
	}

	@Override
	public Connection getConnection() throws SQLException {
		Connection connection = connectionManager.getConnection();
		connection.setAutoCommit(true);
		return connection;
	}

	@Override
	public Connection getConnection(String username, String password) throws SQLException {
		return null;
	}

}
